/*
 * Logger.cpp
 *
 *  Created on: Sep 25, 2011
 *      Author: nicoabie
 */

#include "Logger.h"

Logger::Logger() {
}

void Logger::log(std::string clase, std::string metodo, std::string mensaje) {

	std::cerr << Logger::getDateTime() << " - " << Logger::toUpper(clase)
			<< " [" << metodo << "]: " << mensaje << std::endl;
}

void Logger::log(std::string clase, std::string metodo, std::stringstream* mensaje) {
	log(clase,metodo,mensaje->str());
	mensaje->str(std::string());
}

std::string Logger::getDateTime() {
	time_t rawtime;
	time(&rawtime);

	std::string aux = ctime(&rawtime);

	return std::string(aux.substr(0, aux.size() - 1));
}

std::string Logger::toUpper(std::string s) {
	for (size_t i = 0; i < s.length(); ++i) {
		s[i] = toupper(s[i]);
	};

	return s;
}

Logger::~Logger() {
}

